from helper_functions import sample_circle_disc
import numpy as np
from one_parameter_plotting import Rips_Filtration
/home/ollie/anaconda3/lib/python3.7/site-packages/sklearn/utils/__init__.py:4: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working from collections import Sequence
points = sample_circle_disc(1,100)
show(Rips_Filtration(points,[0.01,2]))
Sample 100 points from a disc of radius 1 and a disc of radius 0.5.
points = np.vstack((sample_circle_disc(1,100, radius = 1, centre = [0,1]),
sample_circle_disc(1,100, radius = 0.5, centre = [0,-1])))
show(Rips_Filtration(points,[0.01,2]))
Sample 80 points on the unit circle and 20 points from the unit disc. Observe the diminished length of the bars in the H_1 barcode
points = sample_circle_disc(0.8,100)
show(Rips_Filtration(points,[0.01,2]))
If we sample a point cloud with noise from 2 different size circles we can no longer distinguish 2 significant bars.
points = np.vstack((sample_circle_disc(0.8,100, radius = 1, centre = [0,1]),
sample_circle_disc(0.8,100, radius = 0.5, centre = [0,-1])))
show(Rips_Filtration(points,[0.01,2]))
Use multiparameter persistence to filter out noise in second variable. We shall filter our point cloud by the k-nearest neighbour function, so that the noise points are excluded when we examing the high density (low codensity) points.
from multiparameter_landscape_plotting import Rips_Codensity_Bifiltration
points = sample_circle_disc(0.8,100)
show(Rips_Codensity_Bifiltration(points,[0,2],
kNN = 5,
maxind=3,
dim = 1))
We can recover 2 features of different scales in the 1st landscape.
points = np.vstack((sample_circle_disc(0.8,100, radius = 1, centre = [0,1]),
sample_circle_disc(0.8,100, radius = 0.5, centre = [0,-1])))
show(Rips_Codensity_Bifiltration(points,[0,1.5],10,maxind=3, dim = 1))
If we have two features of the same size then we detect this in the 2nd landscape.
points = np.vstack((sample_circle_disc(0.8,100, radius = 0.5, centre = [-0.5,0]),
sample_circle_disc(0.8,100, radius = 0.5, centre = [0.5,0])))
show(Rips_Codensity_Bifiltration(points,[0,1],5,maxind=3, dim = 1))
from multiparameter_landscape import multiparameter_landscape
from helper_functions import Compute_Rivet, kNN_filter
one_loop_points = [sample_circle_disc(0.8,100, radius = 0.5, centre = [-0.5,0]) for _ in range(10)]
two_loop_points = [np.vstack((sample_circle_disc(0.8,100, radius = 0.5, centre = [-0.5,0]),
sample_circle_disc(0.8,100, radius = 0.5, centre = [0.5,0]))) for _ in range(10)]
one_loop_rivet_files = [Compute_Rivet(kNN_filter(points, kNN = 5)) for points in one_loop_points]
two_loop_rivet_files = [Compute_Rivet(kNN_filter(points, kNN = 5)) for points in two_loop_points]
one_loop_landscapes = [multiparameter_landscape(rivet_file, bounds = [[0,0],[1,1]], grid_step_size= 0.02) for rivet_file in one_loop_rivet_files]
two_loop_landscapes = [multiparameter_landscape(rivet_file, bounds = [[0,0],[1,1]], grid_step_size= 0.02) for rivet_file in two_loop_rivet_files]
from multiparameter_landscape_plotting import compare_multiparameter_landscape_samples
show(compare_multiparameter_landscape_samples(Samples = [one_loop_landscapes, two_loop_landscapes],
indices = [1,3],
GroupLabels = ['One Loop', 'Two Loops']))
large_loop_points = [sample_circle_disc(0.8,100, radius = 0.5, centre = [-0.5,0]) for _ in range(10)]
small_loop_points = [sample_circle_disc(0.8,100, radius = 0.3, centre = [-0.5,0]) for _ in range(10)]
large_loop_rivet_files = [Compute_Rivet(kNN_filter(points, kNN = 5)) for points in large_loop_points]
small_loop_rivet_files = [Compute_Rivet(kNN_filter(points, kNN = 5)) for points in small_loop_points]
large_loop_landscapes = [multiparameter_landscape(rivet_file, bounds = [[0,0],[1,1]], grid_step_size= 0.02) for rivet_file in large_loop_rivet_files]
small_loop_landscapes = [multiparameter_landscape(rivet_file, bounds = [[0,0],[1,1]], grid_step_size= 0.02) for rivet_file in small_loop_rivet_files]
show(compare_multiparameter_landscape_samples(Samples = [large_loop_landscapes, small_loop_landscapes],
indices = [1,3],
GroupLabels = ['Large Loop', 'Small Loop']))